<?php

/*
 * Copyright (C) 2015 ziroom.com
 * 
 * The whole of life is futile unless you consider it as a sporting proposition.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * This program is created by JIAO Jie.
 * The official website is <http://www.ziroom.com/>
 */

namespace Jiaojie\Util\Xml;

use SimpleXMLElement;

/**
 * XML Tools
 * @author JIAO Jie
 * @date 2015-5-7
 * @version 1.0.0
 * @description
 */
class Tool {

    /**
     * SimpleXMLElement Object To PHP Array Convertion
     * @static
     * @param SimpleXMLElement $element
     * @return array
     */
    public static function xmlElementToArray(SimpleXMLElement $element) {
        $arr = get_object_vars($element);
        foreach ($arr as $key => $val) {
            if ($val instanceof SimpleXMLElement) {
                $arr[$key] = self::xmlElementToArray($val);
            }
        }
        return $arr;
    }

}
